﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Google.GData.Calendar;

namespace PlanoAula.Services
{
    public sealed class GoogleCalendarService
    {
        public static EventFeed ObterEventoCalendario(string url, string email, string senha, DateTime de, DateTime ate)
        {
            CalendarService service = new CalendarService("exampleCo-exampleApp-1");
            if (!string.IsNullOrWhiteSpace(email))
                service.setUserCredentials(email, senha);
            else
                service.Credentials = null;

            string feedUri = url;

            EventQuery myQuery = new EventQuery(feedUri);
            myQuery.StartTime = de;
            myQuery.EndTime = ate;

            EventFeed myResultsFeed = service.Query(myQuery) as EventFeed;
            return myResultsFeed;
        }
    }
}
